package com.zj.study.pojo.query;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import java.time.LocalDate;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * @author 谭耀飞
 * @since 2021.07.0
 */
@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class PaySettlementRecordQuery {

  /**
   * 记录 ID 列表
   */
  private List<Long> rids;

  /**
   * 组织结构编码
   */
  private String orgCode;

  /**
   * 组织结构编码列表
   */
  private String orgCodes;

  /**
   * 结算日期
   */
  private LocalDate settleDate;

  /**
   * 结算日期列表
   */
  private List<LocalDate> settleDates;

  public LambdaQueryWrapper<PaySettlementRecord> toQuery() {
    return new LambdaQueryWrapper<PaySettlementRecord>()
        .in(rids != null, PaySettlementRecord::getRid, rids)
        .eq(orgCode != null, PaySettlementRecord::getOrgCode, orgCode)
        .in(orgCodes != null, PaySettlementRecord::getOrgCode, orgCodes)
        .eq(settleDate != null, PaySettlementRecord::getSettleDate, settleDate)
        .in(settleDates != null, PaySettlementRecord::getSettleDate, settleDates);
  }

}
